﻿using System;
using System.Windows.Forms;

namespace AntdUI_APPDemo.Controls
{
    public partial class Battery : UserControl
    {
        Form form;
        public Battery(Form _form)
        {
            form = _form;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e) { SetBattery(5, Controls); }

        private void button2_Click(object sender, EventArgs e) { SetBattery(-5, Controls); }

        void SetBattery(int value, ControlCollection controls)
        {
            foreach (Control control in controls)
            {
                if (control is AntdUI.Battery) 
                {
                	var battery = (AntdUI.Battery)control;
                	battery.Value += value;
                }
                if (control.Controls.Count > 0) SetBattery(value, control.Controls);
            }
        }
    }
}